package xiegd.study.localTime;

import org.junit.Test;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * @Author: xieguangda
 * @Description:
 * @Date: 2023/3/18 17:15
 */
public class DateTest {

    /**
     * @description:  java.util.date类型是可变类型
     * @param:
     * @return: void
     * @author xieguangda
     * @date: 2023/3/18 17:16
     */
    @Test
    public void test001(){
        Date date = new Date(1000000000);

        Date date2 = date;

        System.out.println("================date:" + date);
        System.out.println("---------------date2:" + date2);

        date.setTime(1600000000L);

        System.out.println("================date:" + date);
        System.out.println("---------------date2:" + date2);
    }

    /**
     * @description: java.time.LocalDateTime类型是不可变类型
     * @param:
     * @return: void
     * @author xieguangda
     * @date: 2023/3/18 17:16
     */
    @Test
    public void test333() throws InterruptedException {
        LocalDateTime nowDate = LocalDateTime.now();
        LocalDateTime nowDate2 = nowDate;

        System.out.println("我是第1时间::" + nowDate);
        System.out.println("我是第2时间::" + nowDate2);

        nowDate =  nowDate.minusDays(1).minusHours(3);


        System.out.println("我是第1时间::" + nowDate);
        System.out.println("我是第2时间::" + nowDate2);
    }


    @Test
    public void mytets() throws ParseException {
        SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat("yyyy-MM-dd");
        Date date = simpleDateFormat2.parse("2020-09-10");
        String newDate = simpleDateFormat2.format(date).toString();

        System.out.println("ThreadName="
                + " 转换成的日期为：" + newDate);
    }

    @Test
    public void shou(){
        SimpleDateFormat simpleDateFormat = DateUtils.getSimpleDateFormat("yyyy-MM-dd");
        SimpleDateFormat simpleDateFormat2 = DateUtils.getSimpleDateFormat("yyyy-MM-dd");
        System.out.println(simpleDateFormat.equals(simpleDateFormat2));
        System.out.println(simpleDateFormat == simpleDateFormat2);
    }
}
